package com.qf.taobei.service.impl;

import com.qf.taobei.entity.RespBean;
import com.qf.taobei.entity.Type;
import com.qf.taobei.mapper.ProductTypeMapper;
import com.qf.taobei.service.ProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductTypeServiceImpl implements ProductTypeService {
    @Autowired
    private ProductTypeMapper productTypeMapper;
    @Override
    public RespBean addProductType(Type type) {
        Integer integer = productTypeMapper.addProductType(type);
        if (integer == 0) {
            return RespBean.respError("添加商品类别失败");
        }
        return RespBean.respSuccess("添加商品类别成功");
    }

    @Override
    public RespBean delProductType(Integer id) {
        Integer integer = productTypeMapper.delProductType(id);
        if (integer == 0) {
            return RespBean.respError("删除商品类别失败");
        }
        return RespBean.respSuccess("删除商品类别成功");
    }

    @Override
    public RespBean updateProductTypeById(Integer id) {
        Integer integer = productTypeMapper.updateProductTypeById(id);
        if (integer == 0) {
            return RespBean.respError("修改商品类别失败");
        }
        return RespBean.respSuccess("修改商品类别成功");
    }

    @Override
    public RespBean queryAllProductType() {
        List<Type> list = productTypeMapper.queryAllProductType();
        if (list.size() == 0) {
            return RespBean.respError("查询失败");
        }
        return RespBean.respSuccess("查询成功", list);
    }
    @Override
    public RespBean queryProductTypeByLevel(Integer level) {
        return null;
    }
}
